import 'package:flutter/material.dart';
import 'package:share/share.dart';

class NewsDetails extends StatefulWidget {
  String title;
  String contain;
  String from;
  String createdAt;
  NewsDetails({Key key, title,contain,from,createdAt}) : super(key: key) {
    this.title = title;
    this.contain = contain;
    this.from = from;
    this.createdAt = createdAt;
  }

  _NewsDetailsState createState() => _NewsDetailsState(this.title,this.contain,this.from,this.createdAt);
}

class _NewsDetailsState extends State<NewsDetails> {
  String title;
  String contain;
  String from;
  String createdAt;
  _NewsDetailsState(title,contain,from,createdAt) {
    this.title = title;
    this.contain = contain;
    this.from = from;
    this.createdAt = createdAt;
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('信息详情'),
        centerTitle: true,
        actions: <Widget>[
          InkWell(
            child:Icon(Icons.more_horiz,size: 36,),
            onTap: (){
              Share.share('${title}' + '\n' + '${contain}' + " \n --来源于广科思政");
            },
            ),
          SizedBox(width: 15,)
        ],
      ),
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Container(
            alignment: Alignment.center,
            margin: EdgeInsets.fromLTRB(10, 20, 10, 10),
            child: Text(
              '${title}',
              style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
            ),
          ),
          Container(
            margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
            child: Text(
              '${contain}',
              style: TextStyle(fontSize: 18),
            ),
          ),
          Container(
            margin: EdgeInsets.fromLTRB(10, 10, 0, 0),
            child: Row(
              children: <Widget>[
                Text('${from}', style: TextStyle(fontWeight: FontWeight.bold)),
                SizedBox(width: 10),
                Text(
                  '${createdAt.substring(0, 10)}',
                  style: TextStyle(color: Color.fromRGBO(175, 175, 175, 1)),
                )
              ],
            ),
          )
        ],
      ),
    );
  }
}